from django.shortcuts import render,redirect,HttpResponse
from .models import *
from django.core.paginator import Paginator
# Create your views here.

def stuList(request,page=1):
    data=student.objects.all()
    pagee=Paginator(data,3)
    pager=pagee.get_page(page)
    return render(request, 'index.html',locals())



def add(request):
    if request.method=='POST':
        stu_name=request.POST.get('stu_name')
        sex=request.POST.get('sex')
        classS=request.POST.get('classS')
        specialized=request.POST.get('specialized')
        img_path=request.POST.get('img_path')
        student.objects.create(stu_name=stu_name,sex=sex,classS=classS,specialized=specialized,img_path=img_path)
        return redirect('stuinfo:show')
    return render(request,'add.html')
def dels(request,id):
    student.objects.get(id=id).delete()
    return redirect('stuinfo:show')

def get_stu(request,id):
    data=student.objects.get(id=id)
    return render(request,'add1.html',{'data':data})